
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="token-tag" prefix="t"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
   <%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>嘉童游乐中心-课程签到表</title>
<jsp:include page="/common/commonCss.jsp" />
<jsp:include page="/common/commonJs.jsp" />
<script type="text/javascript"
	src="${basePath}commonJs/ajaxfileupload.js"></script>

<script type="text/javascript">
	$(document).ready(function() {
		var branId = '${branId}';
		if(branId =='ZB'){
		$("#fkBranId").prepend("<option value=''>"+"全部"+"</option>");
		}
		$("#fkBranId option:[value='']").attr("selected",true);
		initTab("classForm");
		
		$("#exportBtn").click(function() {
			$.messager.confirm('提示', '确定要导出课程签到吗？', function(r) {
				if (r) {
					$("#courseId").val($("#courseChooseId").val());
					$("#courseName").val($("#courseChooseId").find("option:selected").text());
					$("#exportForm").submit();
					$('#qxx').window('close');
				}
			});
		});
	});

	function initTab(formId) {
		var fkMemclassId = $("#memId").val();
		$("#hiddenMemId").val(fkMemclassId);
		var fkBranId = $("#fkBranId").val();
		$("#hiddenFkBranId").val(fkBranId);
		var fkMemId = $("#memName").val();
		$("#hiddenMemName").val(fkMemId);
		var fkPrdId = $("#prdId").val();
		$("#hiddenPrdId").val(fkPrdId);
		var form = $("#" + formId);
		var pagebean = new PageBean(form);
		pagebean.setTableId("classTable");
		pagebean.setCallback(initTable);
		pagebean.setFootId("pagefoot");
		setPagebeanObj(pagebean);
		pagebean.doPage();
	}

	function initTable(data) {
		if (data == null) {
			return;
		}
		$
				.each(
						data,
						function(ind, obj) {
							var i = ind + 1;
							var htm = "<tr>";
							var startDate = obj.startDate;
							var endDate = obj.endDate;
							startDate = getSmpFormatDate(new Date(startDate),
									false);
							endDate = getSmpFormatDate(new Date(endDate), false);
							htm += "<td>" + obj.fkMemclassId + "</td>";
							htm += "<td>" + obj.memName + "</td>";
							htm += "<td>" + obj.prdName + "</td>";
							htm += "<td>" + obj.cnt + "</td>";
							htm += "<td>" + startDate + "~" + endDate + "</td>";
							htm += "<td>" + obj.num + "</td>";
							htm += "<td>"
									+ "<input type='button' class='btn_l' value='签到历史' onclick=\"signHistory('"
									+ obj.fkMemclassId + "')\">" + "</td>";
							$("#classTable").find("tr:eq(" + ind + ")").after(
									htm);
						});

	}

	function upload() {
		var uploadFileName = $("#ui-upload-input").val();
		if ( uploadFileName== '') {
			alertError("请选择上传文件！");
			return false;
		}
		if ( uploadFileName.indexOf(".xls") == -1) {
			alertError("您选择的文件类型不符,请重新选择！");
			return false;
		}
		$.messager.confirm('提示', '确定要导入课程签到吗？', function(r) {
			if (r) {
				$.ajaxFileUpload({
					url : '${basePath}signClass/uploadFile.shtml',
					secureuri : false,
					fileElementId : 'ui-upload-input',
					dataType : 'text',
					success : function(data) {
						data = decodeURI(data);
						if (data != "") {
							alertInfo("文件上传成功！");
							initTab("classForm");
							$("#ui-upload-filepathtxt").val("");
						} else {
							alertError("上传失败，请重试！");
							$("#ui-upload-filepathtxt").val("");
							clean();
						}
					},
					error : function(XMLHttpRequest) {
						 ajaxError(XMLHttpRequest);
						}
				});
			}
		});
	}

	function fileName() {
		var fileName = $("#ui-upload-input").val();
		if (fileName.lastIndexOf("\\") != -1) {
			fileName = fileName.substring(fileName.lastIndexOf("\\") + 1);
		}
		$("#ui-upload-filepathtxt").val(fileName);
	}

	function signHistory(fkMemclassId) {
		clean();
		var memClassId = "";
		memClassId = fkMemclassId;
		$.ajax({
			url : '${basePath}signClass/signedHistory.shtml',
			data : {
				"fkMemclassId" : memClassId
			},
			dataType : "json",
			async : false,
			success : function(result) {
				clean();
				initTable2(result);
			},
			error : function(XMLHttpRequest) {
				 ajaxError(XMLHttpRequest);
				}
		});

	}

	function initTable2(data) {
		if (data == null) {
			return;
		}
		var htm="";
		$.each(data, function(ind, obj) {
			var i = ind + 1;
			htm += "<tr>";
			var signedTime = obj.signedTime;
			signedTime = getSmpFormatDate(new Date(signedTime), true);
			htm += "<td>" + signedTime + "</td>";
			htm += "<td>" + obj.signedBy + "</td>";
			htm += "<td>" + obj.guaSign + "</td></tr>";
			//$("#signedTable").find("tr:eq(" + ind + ")").after(htm);
		});
		$("#signedTable").html(htm);
		$('#fx').window('open');
	}

	function clean() {
		$("#signedTable").find("tr:not(:first)").each(function() {
			$(this).remove();
		});
		$("#ui-upload-filepathtxt").val("");
		$('#fx').window('close');
	}
	
	function selectClass(formId) {
		$("#" + formId + " input:hidden[name='pageNo']").val(1);
		initTab(formId);
	}
</script>

</head>
<body class="bg">
	<div class="content m_auto">
		<div class="content_l mt10">
			<ul>
				<shiro:hasPermission name="signClass/memClass.shtml">
				<li class="content_hover"><a
					href="${basePath}signClass/memClass.shtml"><i
						class="nav_icon_v"></i><br>课程签到表</a></li>
						</shiro:hasPermission>
			</ul>
		</div>
		<div class="content_r mt10">
			<div class="p20">
				<div class="file_single_dl fixed">
					<dl>
						<dd>
							<label>所属门店：</label>
							<div class="uboxstyle">
								<select name="fkBranId" id="fkBranId">
									<c:forEach items="${list}" var="List">;
                            <option value="${List.pkBranId}">
											${List.branName}</option>

									</c:forEach>
								</select>
							</div>
						</dd>
						<dd>
							<label>课程名称：</label>
							<div class="uboxstyle">
								<select name="prdId" id="prdId">
									<option value=''>全部</option>
									<c:forEach items="${list2}" var="List2">;
                            <option value="${List2.pkPrdId}">
											${List2.prdName}</option>

									</c:forEach>
								</select>
							</div>
						</dd>
						<dd>
							<label>学员编号：</label><input type="text" class="iput_t w200"
								id="memId">
						</dd>
						<dd>
							<label>学员姓名：</label>
							<div class="uboxstyle">
								<select name="memName" id="memName">
									<option value=''>全部</option>
									<c:forEach items="${list1}" var="List1">;
                            <option value="${List1.fkMemId}">
											${List1.memName}</option>

									</c:forEach>
								</select>
							</div>
						</dd>

						<dd class="fr">
							<input type="button" class="btn fr ml10" value="查询"
								onclick="selectClass('classForm')"> <input type="button"
								class="btn fr ml10" value="导入签到表"
								onclick="$('#e').window('open')" /> 
								<input type="button" class="btn fr ml10" value="导出签到表" onclick="$('#qxx').window('open')" />
								
								

						</dd>
					</dl>
				</div>
				<form action="${basePath}signClass/memClassDetail.shtml"
					method="post" id="classForm">
					<input type="hidden" name="pageNo" value="1"> <input
						type="hidden" name="pageSize" value="10"> <input
						type="hidden" name="fkMemclassId" id="hiddenMemId"> <input
						type="hidden" name="fkBranId" id="hiddenFkBranId"> <input
						type="hidden" name="memName" id="hiddenMemName"> <input
						type="hidden" name="fkPrdId" id="hiddenPrdId">

				</form>
				<table class="table" id="classTable">
					<tr>
						<th>学员编号</th>
						<th>学员姓名</th>
						<th>课程名称</th>
						<th>课程次数</th>
						<th>课程有效期</th>
						<th>签到课次</th>
						<th>操作</th>
					</tr>

				</table>
				<div class="page fr m10" id="pagefoot"></div>
			</div>
		</div>
	</div>


	<!---弹出层--->
	<div id="fx" class="easyui-window" title="签到历史" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:700px; height:360px; position:relative;">
	<div class="m10">
	
   <div id="scrollTable" style="width: 680px!important;">
            <table class="table" >
                <col width="220px"></col>
                <col width="200px"></col>
                <col></col>
                <tbody>
                    <tr>
                        <th>签到时间</th>
                        <th>学员签名</th>
                        <th>家长签名</th>
                    </tr>
                </tbody>
            </table>
            <div>
            <table class="table">
				<col width="220px"></col>
                <col width="200px"></col>
                <col></col>
                <tbody  id="signedTable">
                </tbody>
            </table>
            </div>
        </div>
   
    </div>

		<div class="btm_btn btm_bg">
			<dl>
				<dd>
					<input type="button" class="btn" onclick="$('#fx').window('close')"
						value="打印">
				</dd>
				<dd>
					<input type="button" class="btn" onclick="clean()" value="取消">
				</dd>
			</dl>
		</div>
	</div>
	<!---弹出层--->


	<!---弹出层--->
	<div id="e" class="easyui-window" title="导入"
		data-options="modal:true,closed:true,iconCls:'icon-save'"
		style="width: 500px; height: 260px; position: relative;">
		<div style="margin: 50px 0 0 100px;">
			<h1 class="mt20">选择导入文件：</h1>
			<p>
			<div class="upload_box">
				<input type="text" id="ui-upload-filepathtxt" class="iput_t fl">
				<span id="ui-upload-holder fr"> <input type="file"
					id="ui-upload-input" name="file" onchange="fileName()">
				</span> <input type="button" class="btn fl ml10" value="浏览">
			</div>
			</p>
		</div>
		<div class="btm_btn btm_bg">
			<dl>
				<dd>
					<input type="button" class="btn" onclick="upload()" value="导入">
				</dd>

				<dd>
					<input type="button" class="btn" onclick="$('#e').window('close')"
						value="取消">
				</dd>
			</dl>
		</div>
	</div>
	<!---弹出层--->

	<!---弹出层--->
<div id="qxx" class="easyui-window" title="导出" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:400px; height:300px; position:relative;">
	<br/><br/>
	<div class="w360_c">
    	课程名称：
		<div class="uboxstyle">
			<select name="prdId" id="courseChooseId">
				<c:forEach items="${list2}" var="List2">;
                        <option value="${List2.pkPrdId}">${List2.prdName}</option>
				</c:forEach>
			</select>
		</div>
    </div>
    <div class="btm_btn btm_bg">
    	<dl>
        	<dd><form action="${basePath}signClass/courseSignExport.shtml" method="post" id="exportForm" name="exportForm">
            		<input type="hidden" name="courseId" id="courseId"/>
            		<input type="hidden" name="courseName" id="courseName"/>
            		<input type="button" id="exportBtn" class="btn fr m010"  value="确定" />
            	</form></dd>
            <dd><input type="button" class="btn" onclick="$('#qxx').window('close')" value="取消"></dd>
        </dl>
    </div>
</div>
<!---弹出层--->
</body>
</html>



